package aom.ju.ss.view.base;

import android.view.View;
import android.widget.LinearLayout;

import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;

public class ListHolder extends RecyclerView.ViewHolder {
    ViewDataBinding viewDataBinding;

    public ListHolder(View itemView) {
        super(itemView);
    }

    public ViewDataBinding getBinding() {
        return viewDataBinding;
    }

    public void setBinding(ViewDataBinding viewDataBinding) {
        this.viewDataBinding = viewDataBinding;
    }

    private boolean isVisible = false;

    public void setVisibility(boolean isVisible) {
        this.isVisible = isVisible;
        RecyclerView.LayoutParams param = (RecyclerView.LayoutParams) itemView.getLayoutParams();
        if (isVisible) {
            param.height = LinearLayout.LayoutParams.WRAP_CONTENT;
            param.width = LinearLayout.LayoutParams.MATCH_PARENT;
            itemView.setVisibility(View.VISIBLE);
        } else {
            itemView.setVisibility(View.GONE);
            param.height = 0;
            param.width = 0;
        }
        itemView.setLayoutParams(param);
    }

    public boolean isVisible() {
        return isVisible;
    }
}